<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" />
		<link rel="stylesheet" href="css/Site.css" />
		<link rel="stylesheet" href="css/zy.all.css" />
		<link rel="stylesheet" href="css/font-awesome.min.css" />
		<link rel="stylesheet" href="css/amazeui.min.css" />
		<link rel="stylesheet" href="css/admin.css" />
		<!--		在标题栏的左侧显示图标 href:图标地址-->
		<link rel="icon" href="images/logo/favicon.ico" type="image/x-icon">
		<!--		在收藏夹里面显示图标 href:图标地址-->
		<link rel="shortcut icon" href="images/logo/favicon.ico" type="image/x-icon">
		<script src="js/jquery.min.js" type="text/javascript"></script>
		<script type="text/javascript">

			//页面加载的时候 异步的方式加载下拉框
			$(function () {
				$.ajax({
					url:"type_all",
					type:"post",
					dataType:"json",
					success:function (result) {
						//alert(JSON.stringify(result));
						for(var i=0;i<result.length;i++){
							$("#productType").append("<option value='"+result[i].tid+"'>"+result[i].tname+"</option>")
						}
					}
				});
			});

			/**
			 * 选中商品类别下拉框
			 * @param tid
			 */
			function getProductsbyType(tid) {
				//根据下拉框的tid，查询对应商品数据
				$("#productSelect").html("");
				if(tid!=-1){
					$.ajax({
						url:"productsByTid",
						type:"post",
						dataType:"json",
						data:{"tid":tid},
						success:function (result) {
							//alert(JSON.stringify(result));
							for(var i=0;i<result.length;i++){
								$("#productSelect").append("<option value='"+result[i].pid+"'>"+result[i].ptitle+"</option>")
							}
						}
					});
				}else{
					$("#productSelect").append("<option value='-1'>请选择商品</option>")
				}
			}

			//商品出库
			function bround_add() {
				var formData=$("#bround_add_form").serialize();
				//alert(formData);
				$.ajax({
					url:"outbround_add",
					data:formData,
					type:"post",
					dataType:"json",
					success:function (result) {
						//alert(JSON.stringify(result));
						if(result.code==200){
							alert("出库成功");
							location.href="outbround_page";
						}else{
							alert("出库失败!");
							location.href="outbround_page";
						}
					}
				});
			}

		</script>
	</head>

	<body>
		<div class="dvcontent">

			<div>
				<!--tab start-->
				<div class="tabs">
					<div class="hd">
						<ul>
							<li class="on" style="box-sizing: initial;-webkit-box-sizing: initial;">出库记录</li>
							 <li class="" style="box-sizing: initial;-webkit-box-sizing: initial;">商品出库</li>
						</ul>
					</div>
					<div class="bd">
						<ul style="display: block;padding: 20px;">
							<li>
								<!--分页显示角色信息 start-->
								<div id="dv1">
									<table class="table" id="tbRecord">
										<thead>
											<tr>
												<th>编号</th>
												<th>商品名称</th>
												<th>商品分类</th>
												<th>出库数量 </th>
												<th>出库日期</th>
												<th>删除</th>
											</tr>
										</thead>
										<tbody>
											<tr th:each="outbround:${pageUtils.data}">
												<td th:text="${outbround.id}"></td>
												<td th:text="${outbround.pname}"></td>
												<td th:text="${outbround.ptype}"></td>
												<td th:text="${outbround.outcount}"></td>
												<td th:text="${outbround.outdate}"></td>
											
												<td class="delete"><button  th:onclick="|outbround_delete(${outbround.id})|"><i class="icon-trash bigger-120"></i>删除</button></td>
											</tr>
										</tbody>
									
									</table>
									<center>
										<a href="type_page?pageIndex=1">首页</a>
										<a th:if="${pageUtils.pageIndex>1}" th:href="|outbround_page?pageIndex=${pageUtils.pageIndex-1}|">上一页</a>
										<a th:each="num:${pageUtils.numbers}" th:class="${pageUtils.pageIndex==num}? a" th:text="|${num} |"></a>

										<a th:if="${pageUtils.pageIndex<pageUtils.pageCount}" th:href="|outbround_page?pageIndex=${pageUtils.pageIndex+1}|">下一页</a>
										<a th:href="|outbround_page?pageIndex=${pageUtils.pageCount}|">尾页</a>
										[<span th:text="${pageUtils.pageIndex}"></span>/<span th:text="${pageUtils.pageCount}"></span>]
										共<span th:text="${pageUtils.totalCount}"></span>条
									</center>
								</div>
								<!--分页显示角色信息 end-->
							</li>
						</ul>
						<ul class="theme-popbod dform" style="display: none;">
								<div class="am-cf admin-main" style="padding-top: 0px;">
			<!-- content start -->
			
	<div class="am-cf admin-main" style="padding-top: 0px;">
		<!-- content start -->
		<div class="admin-content">
			<div class="admin-content-body">
				
				<div class="am-g">
					<div class="am-u-sm-12 am-u-md-4 am-u-md-push-8">
						
					</div>
					<div class="am-u-sm-12 am-u-md-8 am-u-md-pull-4"
						style="padding-top: 30px;">
						<form class="am-form am-form-horizontal"
							action="#" method="post"  id="bround_add_form">
						
							<div class="am-form-group">
								<label for="productType" class="am-u-sm-3 am-form-label">
								分类</label>
								<div class="am-u-sm-9">
									<select name="tid" required id="productType" onchange="getProductsbyType(this.value);">
										<option value="-1">请选择分类</option>
										
										
									</select> <small>分类</small>
								</div>
							</div>
							<div class="am-form-group">
								<label for="productSelect" class="am-u-sm-3 am-form-label">
							商品名称</label>
								<div class="am-u-sm-9">
									<select name="pid" required id="productSelect">
										<option value="-1">请选择商品</option>
										
										
									</select> <small>商品</small>
								</div>
							</div>
							
							<div class="am-form-group">
								<label for="outcount" class="am-u-sm-3 am-form-label">
									数量</label>
								<div class="am-u-sm-9">
									<input type="text" id="outcount" required
										placeholder="数量" name="outcount">
										<small>数量</small>
								</div>
							</div>
							<div class="am-form-group">
								<label for="remark" class="am-u-sm-3 am-form-label">
									备注</label>
								<div class="am-u-sm-9">
									<textarea class="" rows="5" id="remark" name="remark"
										placeholder="输入备注"></textarea>
									<small>250字以内...</small>
								</div>
							</div>
							<div class="am-form-group">
								<div class="am-u-sm-9 am-u-sm-push-3">
									<input type="button" onclick="bround_add();" class="am-btn am-btn-success" value="商品出库" />
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
			
		</div>
		<!-- content end -->
	</div>
							<!--添加 end-->
								</div>
							<!--end-->
						</ul>
					</div>
				</div>
				<!--tab end-->

			</div>

			
			 <script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
              <script src="js/plugs/Jqueryplugs.js" type="text/javascript"></script>
              <script src="js/_layout.js"></script>
             <script src="js/plugs/jquery.SuperSlide.source.js"></script>
			<script>
				var num = 1;
				$(function() {

				 $(".tabs").slide({ trigger: "click" });

				});

				//删除
				var outbround_delete = function(id) {
					$.jq_Confirm({
						message: "您确定要删除吗?",
						btnOkClick: function() {
							$.ajax({
								type: "post",
								url: "outbround_delete",
								data: { id: id },
								success: function(result) {
									if(result.code==200) {
										$.jq_Alert({
											message: "删除成功",
											btnOkClick: function() {
												location.href="outbround_page";
											}
										});
									}else{
										$.jq_Alert({
											message: "删除失败",
											btnOkClick: function() {
												location.href="outbround_page";
											}
										});
									}
								}
							});
						}
					});
				}
			</script>

		</div>
	</body>

</html>